home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_20555.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  29 lines

  1. -- card: 20555 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 7
  9. ----- text -----
  10. 57
  11.  
  12. -- part contents for background part 6
  13. ----- text -----
  14. 2.2  Pointers
  15.  
  16. -- part contents for background part 4
  17. ----- text -----
  18. The value of a POINTER variable is the ADDRESS of a value of another type.  In this case, the type of value contained at this address must be stated.  The '*' qualifier used here declares the variable f_ptr to be a pointer to a floating-point value:
  19.  
  20.     float    *f_ptr;
  21.  
  22. Whenever a pointer variable is used, a non-pointer value must be declared as well, in order to allocate machine addresses to contain the data to be pointed to.  Two operators are commonly used in expressions involving pointers:  '&' ("address of") and '*' ("that which is pointed to by").
  23.  
  24.     float    amplitude = 100.;
  25.     float    *f_ptr;
  26.     f_ptr = &litude;
  27.     amplitude = *f_ptr/2.;
  28.  
  29. These statements declare a pointer 'f_ptr' to a float, as well as a float 'amplitude' which is initialized here to 100.  (It is legal to include an initialization in such declarations.)